package com.cssl.utils;

import org.springframework.stereotype.Component;

import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@Component
public class LoginUtils {

    public Map<String, HttpSession> map;

    public LoginUtils(){
        map=new HashMap<String, HttpSession>();
    }

    public synchronized void addsession(String user,HttpSession session){
        if(map.get(user)==null){
            map.put(user,session);
        }
    }

    public synchronized void delsession(String user){
        map.remove(user);
    }

    public synchronized HttpSession getSession(String user){
        if (map.get(user)!=null){
            return map.get(user);

        }
        return null;
    }
}
